	<div>
		<h3>What would you like to do?</h3>
		<ul class="iconset">
			
		<li><a href="<%= url_for({:action => 'index'}) %>"><span>
				<img alt="event" src="<%= url_for(root_url+"images/icons/back.png") %>" /> <br />
				Back to List</span></a></li>
		
		<div  style="float:right">
			<% if @article.reporter_approving? %>				
				<li><a href="#approve"><span>
				<img alt="event" src="<%= url_for(root_url+"images/icons/approve_check.png") %>" /> <br />
				Approve this Article</span></a></li>
			<% end %>			
		</div>
		
		</ul>						
	</div>


<div class="innerdiv clear" id="article">
	<h2 class="head">Preview Article</h2>
    <div class="innercontent">		
		<h2><%= @article.title %></h2>
		<%= raw @article.body %>
    </div>
</div>

<div class="innerdiv half floatleft">
			<h2 class="head">Approval History</h2>
			<div class="innercontent">
			  <fieldset>
				<legend>Listing</legend>
				
				<table class="full">
					<thead>
						<tr>
							<th>Start Date</th>
							<th>Status</th>
							<th>Comment</th>
							<th>Deadline</th>							
						</tr>
		
					</thead>	
					<tbody class="tooltip-enabled">
						<% @article.article_approvals.each do |his| %>
						<tr>
							<td>
							  <%= his.updated_at %>						
							</td>
							<td>
							  <h5><%= his.status %></h5>						
							</td>
							<td>
							  <%= his.comment %>						
							</td>
							<td>
							  <%= his.deadline %>						
							</td>							
						</tr>
						<% end %>
					</tbody>
				</table>
			  </fieldset>
			</div>
</div>



<div class="innerdiv half floatright" id="approve">
			<h2 class="head-alt">Approve Box</h2>
			<div class="innercontent">
				<%= form_for("", :url => {:action => 'approving'}, :html => {:id => "approving_form"}) do  %>

					  <div style="float:left;margin:0 20px 0px 0">
						<label>Comment: </label>
						<textarea type="text" style="width: 430px;height:150px" name="article_approval[comment]"></textarea>
					  </div>
					  <div style="float:left">
						<label>Actions: </label>
						<select name="article_approval[status]" id="article_approval_status">
							<option value="non">Choose an action ...</option>
							<option value="APPROVED">Approved</option>
							<option value="REEDITING">Re-editing</option>
						</select>
						<p class="validation">
						*required</p>
					  </div>
					  <div style="clear:both;display:none" id="dealine_box">
						<label>Deadline: </label><input type="text" id="deadline" name="article_approval[deadline]" />
					  </div>
					  <div style="clear:both; margin-bottom:10px">
						<input type="hidden" name="article_id" value="<%= @article.id %>" />
						<input type="submit" class="button blue big" value="Submit" />
						<a class="button red big" href="<%= url_for({:action => "index"}) %>">Cancel</a>
						<a href="#article" class="button big gray">View Article</a>
					  </div>

				<% end %>
			</div>
</div>
<script>
	jQuery(function() {
		jQuery( "#deadline" ).datepicker({ dateFormat: 'yy-mm-dd' });
		jQuery("#article_approval_status").change(function() {
			value = jQuery("#article_approval_status").val();
			// alert(value);
			if(value == "REEDITING")
			{
				// alert("Sdfsdfsf");
				jQuery( "#dealine_box" ).css("display", "block");
			}
			else
			{
				//alert(jQuery( "#dealine" ).text())
				jQuery( "#deadline" ).attr("value", "");
				jQuery( "#dealine_box" ).css("display", "none");
			}
			// alert(value);
		      });
		
		$('#approving_form').submit(function() {
			value = jQuery("#article_approval_status").val();
			
			if(value == "non")
			{
				alert("You must select an action.");
				// jQuery( "#dealine_box" ).css("display", "block");
				
				return false;
			}
		});
	});
</script>


